///**
// * Copyright 2018 东方金信
// * <p>
// * Licensed under the Apache License, Version 2.0 (the "License"); you may not
// * use this file except in compliance with the License. You may obtain a copy of
// * the License at
// * <p>
// * http://www.apache.org/licenses/LICENSE-2.0
// * <p>
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// * License for the specific language governing permissions and limitations under
// * the License.
// */
//
//package io.dfjx.modules.sys.shiro;
//
//import io.dfjx.common.exception.RRException;
//import io.dfjx.modules.sys.entity.SysUserEntity;
//import org.apache.shiro.SecurityUtils;
//import org.apache.shiro.crypto.hash.SimpleHash;
//import org.apache.shiro.session.Session;
//import org.apache.shiro.subject.Subject;
//
///**
// * Shiro工具类
// *
// * @author chenshun
// * @email sunlightcs@gmail.com
// * @date 2016年11月12日 上午9:49:19
// */
//public class ShiroUtils {
//	/**  加密算法 */
//	public final static String hashAlgorithmName = "SHA-256";
//	/**  循环次数 */
//	public final static int hashIterations = 16;
//
//	public static String sha256(String password, String salt) {
//		return new SimpleHash(hashAlgorithmName, password, salt, hashIterations).toString();
//	}
//
//	public static Session getSession() {
//		return SecurityUtils.getSubject().getSession();
//	}
//
//	public static Subject getSubject() {
//		return SecurityUtils.getSubject();
//	}
//
//	public static SysUserEntity getUserEntity() {
//		return (SysUserEntity)SecurityUtils.getSubject().getPrincipal();
//	}
//
//	public static Long getUserId() {
//		return getUserEntity().getUserId();
//	}
//
//	public static void setSessionAttribute(Object key, Object value) {
//		getSession().setAttribute(key, value);
//	}
//
//	public static Object getSessionAttribute(Object key) {
//		return getSession().getAttribute(key);
//	}
//
//	public static boolean isLogin() {
//		return SecurityUtils.getSubject().getPrincipal() != null;
//	}
//
//	public static void logout() {
//		SecurityUtils.getSubject().logout();
//	}
//
//	public static String getKaptcha(String key) {
//		Object kaptcha = getSessionAttribute(key);
//		if(kaptcha == null){
//			throw new RRException("验证码已失效");
//		}
//		getSession().removeAttribute(key);
//		return kaptcha.toString();
//	}
//
//}
